package com.itboye.zhujia.adapter;

import java.util.ArrayList;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.itboye.zhujia.R;
import com.itboye.zhujia.bean.HouseBean;
import com.itboye.zhujia.util.XImageLoader;

public class HouseAdapter extends BaseAdapter {
	Activity activity;
	ArrayList<HouseBean> arrayList;
	public HouseAdapter(Activity activity,ArrayList<HouseBean> arrayList){
		this.activity=activity;
		this.arrayList=arrayList;
	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return arrayList==null?0:arrayList.size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return arrayList==null?0:arrayList.get(arg0);
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return arg0;
	}

	@Override
	public View getView(int arg0, View arg1, ViewGroup arg2) {
		// TODO Auto-generated method stub

		 ViewHolder holder=null;
		if(arg1==null){
			arg1=LayoutInflater.from(activity).inflate(R.layout.item_home_tuijian, null);
			holder=new ViewHolder();
			holder.img_icon=(ImageView) arg1.findViewById(R.id.img_icon);
			holder.txt_area=(TextView) arg1.findViewById(R.id.txt_area);
			holder.txt_floor=(TextView) arg1.findViewById(R.id.txt_floor);
			holder.txt_addr=(TextView) arg1.findViewById(R.id.txt_addr);
			holder.money=(TextView) arg1.findViewById(R.id.money);
			holder.tezheng_container=(LinearLayout) arg1.findViewById(R.id.tezheng_container);
			arg1.setTag(holder);
		}else{
			
			holder=(ViewHolder) arg1.getTag();
		}
		XImageLoader.load("", holder.img_icon);
		holder.txt_area.setText("1111");
		holder.txt_floor.setText("1111");
		holder.txt_addr.setText("1111");
		holder.money.setText("1111");
//		holder.tezheng_container
		return arg1;
	}
	
	class ViewHolder{
		ImageView img_icon;
		TextView txt_area,txt_floor,txt_addr,money;
		LinearLayout tezheng_container;//特征容器
	}
}
